package com.ds.infrastructure.hyperspace.console.model.request.container;

import com.ds.infrastructure.hyperspace.console.config.validation.EnumValue;
import com.ds.infrastructure.hyperspace.console.entity.enums.TbContainerConfigEnum;
import com.ds.infrastructure.hyperspace.console.entity.enums.TbPublicEnum;
import com.ds.infrastructure.hyperspace.console.entity.table.TbContainerConfig;
import com.ds.infrastructure.hyperspace.console.model.request.form.PageForm;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

/**
 * @author: yaozhendong
 * @create: 2019-10-18 11:40
 **/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ListContainerForm extends PageForm {

    @NotNull
    private Long stageId;

    @ApiModelProperty(value = "使用状态(非必填):1=可编辑;2=不可编辑", example = "1")
    @EnumValue(value = TbContainerConfigEnum.EDIT_STATE.class, nullable = true)
    private Integer editState;

    public static TbContainerConfig toEntity(ListContainerForm form) {
        TbContainerConfig tbContainerConfig = new TbContainerConfig();
        tbContainerConfig.setStageId(form.getStageId());
        tbContainerConfig.setEditState(form.getEditState());
        tbContainerConfig.setGmtIsDeleted(TbPublicEnum.GMD_IS_DEL.NO.code);
        return tbContainerConfig;
    }
}
